package com.tedu.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.tedu.dao.IOrderDao;
import com.tedu.model.Order;
import com.tedu.service.IOrderService;
@Service
public class OrderService implements IOrderService {
	private IOrderDao orderDao;
	@Resource
	public void setOrderDao(IOrderDao orderDao) {
		this.orderDao = orderDao;
	}
	public void add(Order order) {
		orderDao.add(order);
	}
	public void delete(int id) {
		orderDao.delete(id);
	}
	public void update(Order order) {
		orderDao.update(order);
	}
	public Order load(int id) {
		Order order = orderDao.load(id);
		return order;
	}
	public List<Order> list(int uid) {
		List<Order> orders = orderDao.list(uid);
		return orders;
	}
	public List<Order> listByStatus(int uid, int status) {
		Map<String, Object> args = new HashMap<String, Object>();
		args.put("uid", uid);
		args.put("status", status);
		List<Order> orders = orderDao.listByStatus(args);
		return orders;
	}
	public int countByStatus(int uid, int status) {
		Map<String, Object> args = new HashMap<String, Object>();
		args.put("uid", uid);
		args.put("status", status);
		int count = orderDao.countByStatus(args);
		return count;
	}
	@Override
	public void cancel(int id) {
		orderDao.cancel(id);
		
	}
	@Override
	public List<Order> listSearch(String name, int uid) {
		Map<String, Object> args = new HashMap<String, Object>();
		args.put("uid", uid);
		args.put("name", name);
		
		List<Order> orders = orderDao.listBySearch(args);
		return orders;
	}
	/**
	 * 后台显示
	*/
	@Override
	public List<Order> adminlist(int status) {
		// TODO Auto-generated method stub
		return orderDao.adminlist(status);
	}
	/**
	 * 后台搜索
	*/
	@Override
	public List<Order> adminsearch(String str) {
		// TODO Auto-generated method stub
		return orderDao.adminsearch(str);
	}
	@Override
	public List<Order> adminmouthorder() {
		// TODO Auto-generated method stub
		return null;
	}
}
